<template>
  <div class="manage_order gray">
    <!-- 头部 -->
    <div class="header">
      <span class="iconfont back_icon" @click="back">&#xe616;</span>
      <h3>我的订单列表</h3>
    </div>
    <div class="main" v-if="orderList !== []">
      <div class="order_box" v-for="(item, index) in orderList" :key="index" @click="toOrderDetail(item.order_id)">
        <h3>下单时间：{{ item.create_time }}</h3>
        <p>订单编号：{{ item.order_number }}</p>
        <p>实付：<span class="order_price">￥{{ item.order_price }}</span></p>
        <div class="detail_btn iconfont">&#xe731;</div>
      </div>
    </div>
    <div class="main" v-else>暂无订单</div>
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
  name: 'ManageOrder',
  computed: {
    ...mapState(['orderList'])
  },
  methods: {
    // 返回上一页
    back () {
      this.$router.push('/profile')
    },
    // 前往订单详情页
    toOrderDetail (id) {
      this.$store.commit('getOrderDetail', id)
      this.$router.push('/orderdetail')
    }
  }
}
</script>

<style lang="less" scoped>
.manage_order {
  height: 100%;
  overflow-y: scroll;
    &::-webkit-scrollbar {
      display: none;
    }
}
// 头部
.header {
  position: relative;
  width: 100%;
  height: 1.6rem;
  line-height: 1.6rem;
  font-size: .72rem;
  text-align: center;
  background: #fff;
  .back_icon {
    position: absolute;
    left: .4rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: .8rem;
  }
}
// 已有订单列表
.main {
  padding: .4rem;
}
.order_box {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  position: relative;
  box-sizing: border-box;
  width: 100%;
  height: 4rem;
  font-size: .64rem;
  background: #fff;
  padding: 0.3rem 0.2rem;
  margin-bottom: .4rem;
  border-radius: .2rem;
  .order_price {
    font-size: .64rem;
    font-weight: 600;
  }
  .detail_btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: .4rem;
    font-size: 1rem;
    color: #000;
  }
}
</style>
